/*
Copyright 2009 - 2012 Peter Krajnc, SCREENWORKER

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.compactmvc.services.fontservice
{
	import flash.display.DisplayObject;
	import flash.text.Font;
	
	import org.compactmvc.patterns.Controller;
	import org.compactmvc.patterns.Model;
	
	public class FontService extends Model
	{
		/**
		 * - UnicodeRange -
		 * All
		 * U+0020-U+F002
		 * basic-latin,numerals,punctuation
		 * U+0020-U+007E
		 * Latin 1
		 * U+00A1-U+00FF
		 * Dashes/Special signs
		 * U+2013-U*201F
		 * 
		 * - UnicodeRange Generator -
		 * http://www.zenoplex.jp/tools/unicoderange_generator.html
		 * 
		 * - mimeType -
		 * 
		 * if no font is displayed, replace the mime type. One of them will work!
		 * This property is required if font has no, or uses untypical file extension
		 *  	
		 * application/x-font
		 * application/x-font-truetype
		 * application/x-font-opentype
		 * application/x-font-truetype-collection
		 * 
		 * - AdvancedAntiAliasing -
		 * Check  that you apply the "advancedAntiAliasing=true" property if you use it, otherwise the font will not displayed!
		 * 
		 * - Example Code -
		 * 
		 * [Embed(source='/../assets/fonts/myfont.ttf', fontName='@myfont', mimeType='application/x-font', unicodeRange="U+0020-U+F002", embedAsCFF="false", fontWeight="normal", fontStyle="normal", advancedAntiAliasing="true")] 
		 * private var  font1 : Class;
		 */
		private static var _embedMap : Object;
		
		public function FontService(name:String, controller:Controller)
		{
			super(name, controller);
		}
		
		override public function registerHandler():void
		{
			
			checkCharacterSupport();
		}
		
		public function checkCharacterSupport():void 
		{
			//check embeded FontList
			trace("FontProxy---->checkCharacterSupport--------start");
			
			var embeddedFonts:Array = Font.enumerateFonts(false);	
			for (var p:uint = 0; p < embeddedFonts.length; p++)
			{
				var thisFont : Font  = embeddedFonts[p];
				
				trace("--------------------------");
				trace("embeded font: "+ thisFont.fontName);
			}
			trace("stop--------------------------");
		}
	}
}